<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>学生信息</title>
  <style>
    #tab{

    }
    #tab td {
        text-align: center;
    }
  </style>
    <script>
        function gotoPage(v){
            //window.location.href="list?pageNo="+v.value;
            window.location.href="/student/list?pageNo="+v.value+"&name=[[${name?:''}]]";
        }
        function gotoPage2(v,event){
            console.log("keycode,",event.keyCode);

            if(event.keyCode==13){
                window.location.href="/student/list?pageNo="+v.value+"&name=[[${name?:''}]]";
                return true;
            }
            return false;
        }
        function  gotoP(page){
           document.getElementById("pageNo").value=page;
           document.forms[0].submit();
           return false;
        }
        function resetPage(){
            document.getElementById("pageNo").value=1;
            return true;
        }
    </script>
</head>
<body>
   <h1>课程信息</h1>
   <p th:text="${msg}"></p>
   <p>
       <form action="/student/list">
       <input type="hidden" id="pageNo" name="pageNo" th:value="${p.pageNo}"/>
         <input type="search" name="sname" placeholder="姓名" th:value="${sname?:''}"/>
         <input type="search" name="qq" placeholder="QQ" th:value="${qq?:''}"/>
         <input type="search" name="phone" placeholder="手机号" th:value="${phone?:''}"/>
         入学时间从<input type="date" name="enterStart" placeholder="开始时间" th:value="${#dates.format(enterStart,'yyyy-MM-dd')}"/>
         -
       <input type="date" name="enterEnd" placeholder="截止时间" th:value="${#dates.format(enterEnd,'yyyy-MM-dd')}"/>
         <input type="submit" value="搜索" onclick="resetPage()"/>
       <a href="/student/toAdd">添加</a>
       </form>
   </p>
  <table id="tab" width="85%" border="1" cellpadding="0" cellspacing="0">
     <tr>
       <th>学号</th>
       <th>姓名</th>
       <th>QQ</th>
       <th>入学日期</th>
       <th>微信号</th>
       <th>手机号</th>
       <th>年级号</th>
       <th>身份证照片</th>
       <th>操作</th>
     </tr>
    <tr th:each="s:${p.data}">
      <td th:text="${s.stuno}"></td>
      <td th:text="${s.sname}"></td>
      <td th:text="${s.QQ}"></td>
      <td th:text="${#dates.format(s.enterdate,'yyyy年MM月dd日')}"></td>
      <td th:text="${s.wechat}"></td>
      <td th:text="${s.telephone}"></td>
      <td th:text="${s.gradeid}"></td>
      <td>
          <img width="200px" height="50px" th:src="'/'+${s.idcardpic?:''}" />
      </td>
      <td>
          <a th:href="@{'/student/toUpdate?stuno='+${s.stuno}}">修改</a>
          <a onclick="return window.confirm('真的要删除？')" th:href="@{'/student/del/'+${s.stuno}}">删除</a>
          <a th:href="@{'/student/toDetail?stuno='+${s.stuno}}">详情</a>
      </td>
    </tr>
  </table>
<p>
    <a th:href="@{'/student/list?pageNo=1'}" th:onclick="return gotoP(1)">第一页</a>
    <a th:if="${p.pageNo>1}" th:href="@{'/student/list?pageNo=' + ${p.pageNo-1}}" th:onclick="return gotoP([[${p.pageNo-1}]])">上一页</a>
    <input type="number" th:value="${p.pageNo}" style="width: 36px" name="pageNo" min="1" th:max="${p.pageTotal}" onkeydown="gotoPage2(this,event)" onblur="gotoPage(this)"/>
    /<span th:text="${p.pageTotal}"></span>
    <a th:if="${p.pageNo<p.pageTotal}" th:href="@{'/student/list?pageNo=' + ${p.pageNo+1}}" th:onclick="return gotoP([[${p.pageNo+1}]])">下一页</a>
    <a th:href="@{'/student/list?pageNo=' + ${p.pageTotal}}" th:onclick="return gotoP([[${p.pageTotal}]])">最后一页</a>

</p>
</body>
</html>